-----------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  D:\Ellen\Dropbox\Pajaro_AgInnovation\Submission\JAERE\Replication_Code\Log\S
> umstat_log.log
  log type:  text
 opened on:  29 Nov 2023, 14:16:05

. 
. 
. *CALL DATASET
. use "Data\Parcel_Clean_yearrun_20230626.dta"

. bysort year_run: gen nparcel = [_N]

. 
. *FILE CALLS QUARTERLY DATASET BELOW 
. 
. ********************************************************************************
. *FIGURE 12: PARCEL COUNT BY YEAR 
. ********************************************************************************
. preserve

. collapse (mean) nparcel, by (year_run)

. twoway connected nparcel year_run if year_run <11, ylabel(600(50)800) xlabel(1(3)10) sc
> heme(s1color) ytitle(Parcel Count) xtitle(Year) ///
> tlabel(1 "2006" 4 "2009" 7 "2012" 10 "2015", gextend)

. graph save "Figures\WellCount_$outputdate.gph", replace
(file Figures\WellCount_20231125.gph saved)

. graph export "Figures\WellCount_$outputdate.png", replace
(file Figures\WellCount_20231125.png written in PNG format)

. restore

. 
. *Balance the panel
. bysort parcelnum: gen ntime = [_N]

. sum ntime

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       ntime |     28,848    5.919024    6.578618          1         15

. keep if ntime==`r(max)'
(19,488 observations deleted)

. 
. *Drop 2010
. drop if year_run==5 
(624 observations deleted)

. 
. *How many parcels in dataset? 624 after balancing 
. by parcelnum, sort: gen nvals_parcel = _n == 1 

. preserve 

. keep if inside==0
(985 observations deleted)

. count if nvals_parcel
  554

. restore

. 
. preserve 

. keep if inside==1
(7,751 observations deleted)

. count if nvals_parcel
  70

. restore

. 
. egen N_parcelyear = count(nvals_parcel), by (parcelnum year_run)

. bysort year_run parcelnum: gen wellcount=_N 

. 
. ********************************************************************************
. *Table 1: Summary Statistics ANNUAL WATER VARIABLES
. ********************************************************************************
. *By DWZ:
. eststo clear

. bys inside: eststo: estpost tabstat extraction price delivered delivered_rate  CL_zoned
> ate gw_depth if year_run <11, stat(count mean sd) col(stat)

-----------------------------------------------------------------------------------------
-> 0

Summary statistics: count mean sd
     for variables: extraction price delivered delivered_rate CL_zonedate gw_depth

             |  e(count)    e(mean)      e(sd) 
-------------+---------------------------------
  extraction |      4981   61.56458   93.82154 
       price |      4981   146.4759   37.21995 
   delivered |      4981          0          0 
delivered_~e |         0          .          . 
 CL_zonedate |      4981   57.46683   7.264176 
    gw_depth |      3797   134.1005   99.81081 
(est1 stored)

-----------------------------------------------------------------------------------------
-> 1

Summary statistics: count mean sd
     for variables: extraction price delivered delivered_rate CL_zonedate gw_depth

             |  e(count)    e(mean)      e(sd) 
-------------+---------------------------------
  extraction |       635   112.9908   139.3895 
       price |       635    165.834   51.98632 
   delivered |       635   2846.583   1376.342 
delivered_~e |       635   295.9652   31.76806 
 CL_zonedate |       635   130.7361   27.45682 
    gw_depth |       493   84.79443   60.68553 
(est2 stored)

. esttab using "Tables\SumStat_extraction_annual_byDWZ_lim_$outputdate.tex", replace ///
> nomtitles title("Descriptive Statistics") cells("count(fmt(0)) mean(fmt(2)) sd(fmt(2))"
> ) label 
(output written to Tables\SumStat_extraction_annual_byDWZ_lim_20231125.tex)

. 
. *Aggregate:
. ********************************************************************************
. eststo clear

. estpost tabstat gw_depth extraction price delivered_rate delivered CL_zonedate flat_rat
> e time_of_use rent_irrigated if year_run <11, ///
> stat(count mean sd min max) col(stat)

Summary statistics: count mean sd min max
     for variables: gw_depth extraction price delivered_rate delivered CL_zonedate flat_r
> ate_1B time_of_use_rate_5B rent_irrigated_cropland_peracre

             |  e(count)    e(mean)      e(sd)     e(min)     e(max) 
-------------+-------------------------------------------------------
    gw_depth |      4290   128.4343   97.40059   8.743001   1428.872 
  extraction |      5616   67.37934   101.3217          0   1063.572 
       price |      5616   148.6647   39.64087         80        220 
delivered_~e |       635   295.9652   31.76806        262      340.5 
   delivered |      5616   321.8625   1013.237          0   4909.048 
 CL_zonedate |      5616   65.75138   25.89184   41.39576     176.17 
flat_rate_1B |      4367   .2327565   .0139068     .20797     .25359 
time_of_u~5B |      4367   .1254142   .0076199   .1105925     .13628 
rent_irrig~e |      4360   1472.313   219.5594     1152.5       1820 

. esttab using "Tables\SumStat_extraction_annual_lim_$outputdate.tex", replace ///
> nomtitles title("Descriptive Statistics") cells("count(fmt(0)) mean(fmt(2)) sd(fmt(2)) 
> min(fmt(2)) max(fmt(2))") label 
(output written to Tables\SumStat_extraction_annual_lim_20231125.tex)

. 
. ********************************************************************************
. ********************************************************************************
. use "Data\Parcel_Clean_20230626.dta", clear

. 
. preserve

. *Balance the panel
. bysort parcelnum: gen ntime = [_N]

. sum ntime

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       ntime |     43,601    61.32862    8.353222          1         64

. keep if ntime==`r(max)'
(9,233 observations deleted)

. 
. *Drop 2010
. drop if year ==2010
(2,148 observations deleted)

. ********************************************************************************
. *Table: Summary Statistics QUARTERLY VARIABLES
. ********************************************************************************
. 
. *By DWZ
. eststo clear

. bys inside: eststo: estpost tabstat  extraction price delivered delivered_rate  CL_zone
> date gw_depth if year<2016, ///
> stat(count mean sd) col(stat)

-----------------------------------------------------------------------------------------
-> 0

Summary statistics: count mean sd
     for variables: extraction price delivered delivered_rate CL_zonedate gw_depth

             |  e(count)    e(mean)      e(sd) 
-------------+---------------------------------
  extraction |     19000   16.48119   29.35541 
       price |     19000     146.55   39.20113 
   delivered |     19000          0          0 
delivered_~e |         0          .          . 
 CL_zonedate |     15675   74.09679   88.58913 
    gw_depth |     12964    126.836   76.55178 
(est1 stored)

-----------------------------------------------------------------------------------------
-> 1

Summary statistics: count mean sd
     for variables: extraction price delivered delivered_rate CL_zonedate gw_depth

             |  e(count)    e(mean)      e(sd) 
-------------+---------------------------------
  extraction |      2480   26.44823   38.64883 
       price |      2480      164.5   53.27659 
   delivered |      2480   677.9268   524.0641 
delivered_~e |      2480      293.8   33.02272 
 CL_zonedate |      2108   145.6772   81.92332 
    gw_depth |      1736   83.49073   60.03021 
(est2 stored)

. esttab using "Tables\SumStat_extraction_quarterly_byDWZ_lim_$outputdate.tex", replace /
> //
> nomtitles title("Descriptive Statistics") cells("count(fmt(0)) mean(fmt(2)) sd(fmt(2))"
> ) label 
(output written to Tables\SumStat_extraction_quarterly_byDWZ_lim_20231125.tex)

. 
. *Aggregate
. eststo clear

. estpost tabstat gw_depth extraction price delivered_rate delivered CL_zonedate flat_rat
> e time_of_use if year<2016, ///
> stat(count mean sd min max) col(stat)

Summary statistics: count mean sd min max
     for variables: gw_depth extraction price delivered_rate delivered CL_zonedate flat_r
> ate_1B time_of_use_rate_5B

             |  e(count)    e(mean)      e(sd)     e(min)     e(max) 
-------------+-------------------------------------------------------
    gw_depth |     14700   121.7172   76.08622   8.160755   588.8641 
  extraction |     21480   17.63194   30.73739          0    524.694 
       price |     21480   148.6224   41.47042         80        235 
delivered_~e |      2480      293.8   33.02272        262        348 
   delivered |     21480   78.27088   280.4207          0   2029.021 
 CL_zonedate |     17783   82.58195   90.82026   22.62343   564.2434 
flat_rate_1B |     15036   .2343875   .0139216     .20752     .25359 
time_of_u~5B |     15036   .1262266   .0075497     .11027     .13628 

. esttab using "Tables\SumStat_extraction_quarterly_lim_$outputdate.tex", replace ///
> nomtitles title("Descriptive Statistics") cells("mean(fmt(2)) sd(fmt(2)) min(fmt(2)) ma
> x(fmt(2))") label 
(output written to Tables\SumStat_extraction_quarterly_lim_20231125.tex)

. restore

. ********************************************************************************
. *FIGURE 3: Prices by zone over time LIMITED SAMPLE
. ********************************************************************************
. 
. twoway (connected price date if inside ==0 & date <222, sort lwidth(medthick) msymbol(m
> edium) msize(small)) ///
> (connected price date if inside==1 & date <222, sort lwidth(medium) msymbol(triangle) m
> size(vsmall)), ///
> legend (label (1 Outside DWZ) label (2 Inside DWZ) rows(1)) ylabel(50(50)250) ///
> scheme (s1color) ytitle("Groundwater Price ($/AF)") xline(202, lcolor(black) lpattern(d
> ash)) ///
> tlabel(180 "Q1/2005" 192 "Q1/2008" 204 "Q1/2011" 216 "Q1/2014", gextend)
(note:  named style medium not found in class symbol, default attributes used)

. graph save "Figures\PriceByYear_$outputdate.gph", replace
(file Figures\PriceByYear_20231125.gph saved)

. graph export "Figures\PriceByYear_$outputdate.png", width(4000) replace
(file Figures\PriceByYear_20231125.png written in PNG format)

. 
. 
. ********************************************************************************
. *FIGURE 7: Energy price changes over time
. ********************************************************************************
. preserve

. keep if date>191
(8,195 observations deleted)

. keep if date <224
(13,524 observations deleted)

. twoway (connected flat_rate date, sort lwidth(medthick) msymbol(medium) msize(vsmall)) 
> ///
> (connected time_of_use date, sort lwidth(medium) msize(vsmall)), ///
> scheme (s1color) ytitle("Electricity rates ($/kwh)") xline(202, lcolor(black) lpattern(
> dash)) ///
> tlabel(192 "Q1/2008" 204 "Q1/2011" 216 "Q1/2014", gextend)
(note:  named style medium not found in class symbol, default attributes used)

. graph save "Figures\EnergyPriceByYear_$outputdate.gph", replace
(file Figures\EnergyPriceByYear_20231125.gph saved)

. graph export "Figures\EnergyPriceByYear_$outputdate.png", width(4000) replace
(file Figures\EnergyPriceByYear_20231125.png written in PNG format)

. restore

. 
. ********************************************************************************
. *FIGURE 8: Average extraction by zone 
. ********************************************************************************       
>          
. preserve

. collapse (mean) extraction if year<2016, by (inside date)

. twoway (connected extraction date if inside==0, sort msize(small)) ///
> (connected extraction date if inside==1, sort msize(small) lpattern(dash)),  ///
>         ytitle(Mean Groundwater Extraction (AF)) xline(202, lcolor(black)) ///
>         tlabel(180 "Q1/2005" 192 "Q1/2008" 204 "Q1/2011" 216 "Q1/2014" 224 "Q1/2016" , 
> gextend) scheme(s1color) ///
> legend (label (1 Outside DWZ) label (2 Inside DWZ) rows(1))

. graph save "Figures\AvgExtraction_lim_$outputdate.gph", replace
(file Figures\AvgExtraction_lim_20231125.gph saved)

. graph export "Figures\AvgExtraction_lim_$outputdate.png", replace
(file Figures\AvgExtraction_lim_20231125.png written in PNG format)

. restore

. 
. ********************************************************************************
. *FIGURE 11: Average Gross Water Use (Adding Recycled water deliveries)
. ********************************************************************************
. preserve

. collapse (mean) extraction (mean) delivered_percap if year<2016, by (inside date)

. gen extract_plus = extraction + delivered_percap

. twoway (connected extract_plus date if inside==0, sort msize(small)) ///
> (connected extract_plus date if inside==1, sort msize(small) lpattern(dash)),  ///
>         ytitle(Mean Extraction plus Recycled (AF)) xline(202, lcolor(black)) ///
>         tlabel(180 "Q1/2005" 192 "Q1/2008" 204 "Q1/2011" 216 "Q1/2014" 224 "Q1/2016" , 
> gextend) scheme(s1color) ///
> legend (label (1 Outside DWZ) label (2 Inside DWZ) rows(1))

. graph save "Figures\AvgExtraction_plus_lim_$outputdate.gph", replace
(file Figures\AvgExtraction_plus_lim_20231125.gph saved)

. graph export "Figures\AvgExtraction_plus_lim_$outputdate.png", replace
(file Figures\AvgExtraction_plus_lim_20231125.png written in PNG format)

. restore

. 
. 
. ********************************************************************************
. *FIGURE 10: Recycled Water Deliveries by Zone
. ********************************************************************************
. preserve

. collapse (median) delivered (mean) delivered_rate, by (inside date)

. label var delivered "Recycled Deliveries"

. label var delivered_rate "Rate"

. keep if date < 224
(40 observations deleted)

. 
. twoway (connected delivered date if inside==0, sort msize(vsmall)) ///
> (connected delivered date if inside==1, sort msize(vsmall)),  ///
>         ytitle(Total Water Deliveries (AF)) ///
>         tlabel(180 "Q1/2005" 192 "Q1/2008" 204 "Q1/2011" 216 "Q1/2014", gextend) scheme
> (s1color) ///
> legend (label (1 Outside DWZ) label (2 Inside DWZ) rows(1))

. graph save "Figures\Delivered_$outputdate.gph", replace
(file Figures\Delivered_20231125.gph saved)

. graph export "Figures\Delivered_$outputdate.png", width(4000) replace
(file Figures\Delivered_20231125.png written in PNG format)

. restore

. 
. log close
      name:  <unnamed>
       log:  D:\Ellen\Dropbox\Pajaro_AgInnovation\Submission\JAERE\Replication_Code\Log\S
> umstat_log.log
  log type:  text
 closed on:  29 Nov 2023, 14:16:17
-----------------------------------------------------------------------------------------
